/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package percussiongenerator.commands;

import org.jfonia.connect5.basics.MutableValueNode;
import percussiongenerator.model.Track;
import percussiongenerator.sound.SimpleInstrument;

/**
 *
 * @author Jannes Plyson
 */
public class ChangeInstrument implements ICommand{
    MutableValueNode<SimpleInstrument> instrumentNode;
    private SimpleInstrument oldInstrument, newInstrument;

    public ChangeInstrument(MutableValueNode<SimpleInstrument> instrumentNode, SimpleInstrument newInstrument){
        this.instrumentNode = instrumentNode;
        this.newInstrument = newInstrument;
    }

    public void execute() {
        oldInstrument = instrumentNode.getValue();        
        instrumentNode.setValue(newInstrument);
    }

    public void undo() {        
        instrumentNode.setValue(oldInstrument);
    }

}
